package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Xianxingtime;
import com.ruoyi.system.service.IXianxingtimeService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 限行时间段 信息操作处理
 * 
 * @author chengenjiang
 * @date 2019-07-30
 */
@Controller
@RequestMapping("/system/xianxingtime")
public class XianxingtimeController extends BaseController
{
    private String prefix = "system/xianxingtime";
	
	@Autowired
	private IXianxingtimeService xianxingtimeService;
	
	@RequiresPermissions("system:xianxingtime:view")
	@GetMapping()
	public String xianxingtime()
	{
	    return prefix + "/xianxingtime";
	}
	
	/**
	 * 查询限行时间段列表
	 */
	@RequiresPermissions("system:xianxingtime:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Xianxingtime xianxingtime)
	{
		startPage();
        List<Xianxingtime> list = xianxingtimeService.selectXianxingtimeList(xianxingtime);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出限行时间段列表
	 */
	@RequiresPermissions("system:xianxingtime:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Xianxingtime xianxingtime)
    {
    	List<Xianxingtime> list = xianxingtimeService.selectXianxingtimeList(xianxingtime);
        ExcelUtil<Xianxingtime> util = new ExcelUtil<Xianxingtime>(Xianxingtime.class);
        return util.exportExcel(list, "xianxingtime");
    }
	
	/**
	 * 新增限行时间段
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存限行时间段
	 */
	@RequiresPermissions("system:xianxingtime:add")
	@Log(title = "限行时间段", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Xianxingtime xianxingtime)
	{		
		return toAjax(xianxingtimeService.insertXianxingtime(xianxingtime));
	}

	/**
	 * 修改限行时间段
	 */
	@GetMapping("/edit/{xianXingTimeId}")
	public String edit(@PathVariable("xianXingTimeId") Integer xianXingTimeId, ModelMap mmap)
	{
		Xianxingtime xianxingtime = xianxingtimeService.selectXianxingtimeById(xianXingTimeId);
		mmap.put("xianxingtime", xianxingtime);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存限行时间段
	 */
	@RequiresPermissions("system:xianxingtime:edit")
	@Log(title = "限行时间段", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Xianxingtime xianxingtime)
	{		
		return toAjax(xianxingtimeService.updateXianxingtime(xianxingtime));
	}
	
	/**
	 * 删除限行时间段
	 */
	@RequiresPermissions("system:xianxingtime:remove")
	@Log(title = "限行时间段", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(xianxingtimeService.deleteXianxingtimeByIds(ids));
	}
	
}
